package sk.isomi.minihr.entities;

import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;

import sk.isomi.enums.ProjectTypes;

public class Project {
	private Integer id;
	private String name;
	private Date startDate;
	private int length;
	private Double budget;
	private ProjectTypes type;
	private Manager manager;
	private Client client;
	private ArrayList<Employee> workers;
	
	public Project(Integer id, String name, Date startDate, int length,	Double budget, ProjectTypes type) {
		setId(id);
		setName(name);
		setStartDate(startDate);
		setLength(length);
		setBudget(budget);
		setType(type);
		setWorkers(new ArrayList<Employee>());
	}
	
	public Date getEndDate() {
		Calendar calendar = Calendar.getInstance();
		calendar.setTime(getStartDate());
		calendar.add(Calendar.DAY_OF_YEAR, getLength());
		return calendar.getTime();
	}

	public Integer getId() {
		return id;
	}

	private void setId(Integer id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public Date getStartDate() {
		return startDate;
	}

	public void setStartDate(Date startDate) {
		this.startDate = startDate;
	}

	public int getLength() {
		return length;
	}

	public void setLength(int length) {
		this.length = length;
	}

	public Double getBudget() {
		return budget;
	}

	public void setBudget(Double budget) {
		this.budget = budget;
	}

	public ProjectTypes getType() {
		return type;
	}

	public void setType(ProjectTypes type) {
		this.type = type;
	}

	public Manager getManager() {
		return manager;
	}

	public void setManager(Manager manager) {
		this.manager = manager;
	}

	public Client getClient() {
		return client;
	}

	public void setClient(Client client) {
		this.client = client;
	}

	public ArrayList<Employee> getWorkers() {
		return workers;
	}

	public void setWorkers(ArrayList<Employee> workers) {
		this.workers = workers;
	}

	@Override
	public String toString() {
		return String.format("Project [id=%s, name=%s, startDate=%s, length=%s, budget=%s, manager=%s, client=%s]",	id, name, startDate, length, budget, manager, client);
	}
	
	@Override
	public boolean equals(Object obj) {
		return obj != null && obj instanceof Project && ((Project) obj).getId() == getId();
	}
}
